#! /bin/bash
#PBS -N Test_MPI
#PBS -q class
#PBS -o output/test_mpi.out
#PBS -e output/test_mpi.err
#PBS -d /nethome/jchua3/vetter/cse6220/project/test/
#PBS -l nodes=8

cd $PBS_O_WORKDIR

mpirun -n 1 -machinefile $PBS_NODEFILE R --vanilla > test_mpi.out <<EOF

library(snow)
cl <- makeCluster($np, type="MPI")
clusterCall(cl, function() Sys.info()[c("nodename","machine")])
clusterCall(cl, runif, $np)
stopCluster(cl)
mpi.quit()
EOF



